package com.vincent.sciinfo.mapper;

import com.vincent.sciinfo.pojo.Paper;
import com.vincent.sciinfo.pojo.PaperExample;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PaperMapper {
    long countByExample(PaperExample example);

    int deleteByExample(PaperExample example);

    int deleteByPrimaryKey(String resultuuid);

    int insert(Paper record);

    int insertSelective(Paper record);

    List<Paper> selectByExample(PaperExample example);

    Paper selectByPrimaryKey(String resultuuid);

    int updateByExampleSelective(@Param("record") Paper record, @Param("example") PaperExample example);

    int updateByExample(@Param("record") Paper record, @Param("example") PaperExample example);

    int updateByPrimaryKeySelective(Paper record);

    int updateByPrimaryKey(Paper record);


    @Update("update paper set score = #{score} where paperName = #{paperName}")
    int updateByScoreColumn(@Param("paperName") String paperName, @Param("score") int score);

    @Update("update paper set score = (select score from scorestandard where name = #{paperTypeId} ) where resultUUid = #{resultUUid}")
    int updatePaperScoreByType(@Param("resultUUid") String paperId,@Param("paperTypeId") String paperTypeId);

    @Insert("insert into paper(resultUUid, teacherId, firstName, allName, endTime, paperName, paperTypeId, supportFun, checkFlag) values (#{p.resultuuid}, #{p.teacherid}, #{p.firstname}, #{p.allname},  #{p.endtime}, #{p.papername}, #{p.papertypeid}, #{p.supportfun}, #{p.checkflag} )")
    int insertPart(@Param("p") Paper paper);
}